home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
zbpc_460.zip
/
DEMOS.EXE
/
DOLLARS.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-04-13
|
2KB
|
78 lines
'Routine to translate numbers to dollars and cents in verb
DIM Word$(28): FOR I%=2 TO 28: READ Word$(I%): NEXT
DATA twenty,thirty,forty,fifty,sixty,seventy,eighty,ninenty
DATA one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve, THIRTEEN,FOURTEEN,FIFTEEN,SIXTEEN,SEVENTEEN,EIGHTEEN,NINETEEN
CLS
"Input"
INPUT "Enter amount "; Sum# : IF Sum# = 0 END
P$ = "": IF Sum# <= 198000000000000# LSum#=Sum#
Cents%=INT((LSum#-INT(LSum#))*100#+.5#) :LSum#=INT(LSum#)
LONGIF LSum#
GOSUB "Calc"
IF LSum# > 1 P$ = P$ + "dollars and " ELSE P$ = P$ + "dollar and "
ENDIF
LONGIF Cents%
X$ = "0"+MID$(STR$(Cents%),2,2)
LSum# = VAL (X$)
GOSUB "Calc"
XELSE
P$=P$+"no "
ENDIF
IF LSum# > 1 P$ = P$ + "cents" ELSE P$ = P$ + "cent"
LONGIF LEN(P$)
PRINT P$
PRINT
XELSE
PRINT "Exceeds accuracy limits, use a smaller number!"
ENDIF
GOTO "Input"
"Calc"
LONG IF LSum# > 999999999999#
T5# = LSum#-INT(LSum#/1000000000000#)*1000000000000#
LSum# = INT(LSum#/1000000000000#)
GOSUB "Calc"
P$ =P$ + "trillion "
LSum# = T5#
ENDIF
LONGIF LSum# > 999999999#
T4# = LSum#-INT(LSum#/1000000000#)*1000000000#
LSum# = INT(LSum#/1000000000#)
GOSUB "Calc"
P$ = P$ + "billion "
LSum# = T4#
ENDIF
LONGIF LSum# > 999999#
T3# = LSum#-INT(LSum#/1000000#)*1000000#
LSum# = INT(LSum#/1000000#)
GOSUB "Calc"
P$ = P$ + "million "
LSum# = T3#
ENDIF
LONGIF LSum# > 999#
T2# = LSum#-INT(LSum#/1000#)*1000#
LSum# = INT(LSum#/1000#)
GOSUB "Calc"
P$ = P$ + "thousand "
LSum# = T2#
ENDIF
LONGIF LSum# > 99#
T1# = LSum#
LSum# = INT(LSum#/100#)
GOSUB "Calc"
P$ = P$ + "hundred "
LSum# = T1#-LSum#*100#
ENDIF
LONG IF LSum# > 19#
P$ = P$ + Word$(INT(LSum#/10#)): LSum# = LSum#-10#*INT(LSum#/10#)
LONGIF LSum#
P$ =P$ + "-"
XELSE
P$=P$ +" "
ENDIF
ENDIF
IF LSum# P$ = P$ + Word$(LSum#+9#)+" "
RETURN